This post is all about the solution of the C. Prepend and Append Codeforces Round #849 (Div. 4) Problem solution.

C. Prepend and Append Codeforces Round #849 (Div. 4) Problem solution

Codeforces

Problem Statement :

Timur began with a binary string s (possibly of length 0). He repeated the following operation several times (possibly zero):

Add a zero to one end of the string and a one to the other. Starting with the string 1011, you can get either 010111 or 110110.
Timur's final string is given to you. What is the length of the shortest string he could have begun with?
† A binary string is a string (which could be the empty string) with characters that are either 0 or 1.



Format of Input :

Timofey visited a well-known summer school and discovered a tree with n vertices. A tree is an undirected connected graph with no cycles.
Except for c0, every vertex in this tree is white. The vertex c0 is black in colour.
Timofey wishes to make all of the vertices of this tree black. He uses n1 operations to accomplish this. During the i-th operation, he selects the currently white vertex ci and paints it black.
Let us define tree positivity as the shortest distance between all pairs of different black vertices in it. The number of edges on the path from v to u is the distance between the vertices v and u.
Timofey wants to know the current state of affairs after each operation.

Format of the Output :

For every test case, print three strings a, b, and c separated by spaces on a single line — capybara names, such that writing them without spaces results in a line s. ab and cb, or ba and bc, must be satisfied.

If you have several options for restoring the names, print any of them. If the names are unable to be recovered, print ":(" (without quotes)


Also Check this out:-

D. Distinct Split Codeforces Round #849 (Div. 4) Problem solution, Click Here
E. Negatives and Positives Codeforces Round #849 (Div. 4) Problem solution, Click Here
Solution of the Problem: Click Here